10. CodeBuild

CodeBuild

CodeBuild: An AWS Continuous Integration service

Continuous Integration: The first part of Continuous Delivery

FSND C4 L2 A11 CodeBuild

Codebuild recap

CodeBuild Recap

  • Continuous Integration: frequent check-ins to a central repository which trigger automated builds and tests
  • CodeBuild: A fully managed continuous integration system offered by AWS
  • Codebuild can be added as an action to a CodePipeline stage

CodeBuild can be added to a continuous delivery pipeline to handle continuous integration.

CodeBuild can be added to a continuous delivery pipeline to handle continuous integration.

CodeBuild

One of the motivations for Continuous Integration is to:

SOLUTION: Catch bugs earlier in the development process

CodeBuild

CodeBuild is designed to do the following

SOLUTION:
  • Compile code
  • Run tests
  • Create deployable packages

More resources

Additional Resources

  • General information about CodeBuild can be found here .
  • AWS instructions on how to create a pipeline with CodeBuild and CodePipeline can be found here .
  • Documentation on Buildspec files can be found here

Build Spec File

The instructions that a CodeBuild stage will follow are put in a build spec file named buildspec.yml . This file contains all of the commands that the build will run and any related settings. This file should be placed at the root of your project directory. Amazon supplies CodeBuild samples , you can see examples of build spec files there. The sample for a simple Docker custom image has the build spec:

version: 0.2

phases:
  install:
    commands:
      - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
      - timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
  pre_build:
    commands:
      - docker build -t helloworld .
  build:
    commands:
      - docker images
      - docker run helloworld echo "Hello, World!" 

You can see that it is divided into the phases ‘install’, ‘pre_build’, and ‘build’. Each phase contains commands, which are the same commands you would use to run Docker locally. You can read about the build spec syntax here